<?php 
/**
 * 公共管理控制器
 */
class CommonController extends Controller{
	//处理导航
	public function navigation(){
		//导航栏的分类
		$navData = K('Category')->where("pid=0 and is_nav=1")->all();
		$this->assign('navData',$navData);
		//全部分类顶级分类
		$cateTopAll = K('Category')->where("pid=0")->all();
		$this->assign('cateTopAll',$cateTopAll);
		//处理顶部头像
		if(isset($_SESSION['uid'])){
			$face = current(K('User')->field('face')->where("uid={$_SESSION['uid']}")->find());
			$this->assign('face',$face);
		}
		
	}
	
	//处理分类数据
	public function cate(){
		$cateData = K('Category')->all();
		$cateData = K('Category')->where("pid=0")->all();
		//分配顶级分类
		$this->assign('cateData',$cateData);
		$cateData = Data::tree($cateData,'cname');
		//重组分类数组 三级分类
		foreach ($cateData as $k => $v) {
			$cateData[$k]['son'] = K('Category')->where("pid={$v['cid']}")->all();
			foreach($cateData[$k]['son'] as $kk => $vv){
				$cateData[$k]['son'][$kk]['son'] = K('Category')->where("pid={$vv['cid']}")->all();
			}
		}
		
		//获取女人广场的分类
		$wenmanCate = $cateData[4]['son'];
		$this->assign('wenmanCate',$wenmanCate);
		//获取男人广场分类
		$manCate = $cateData[5]['son'];
		$this->assign('manCate',$manCate);
		//获取生活家分类
		$lifeCate = $cateData[6]['son'];
		$this->assign('lifeCate',$lifeCate);
		//获取手工作坊
		$handCate = $cateData[8]['son'];
		$this->assign('handCate',$handCate);
		//获取vintage小铺
		$vinCate = $cateData[9]['son'];
		$this->assign('vinCate',$vinCate);
		//方法返回三级分类数组
		return $cateData;
		
	}
	
	/**
	 * 退出登录
	 */
	public function out(){
		unset($_SESSION['username']);
		unset($_SESSION['uid']);
		unset($_SESSION['nick']);
		$this->success('退出成功',U('Index/Index/index'));
	}
	
	
	
	
	
	
	
}

















 ?>